package com.tyl.controller.user;

import com.tyl.pojo.User;
import com.tyl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/go")
public class UserController {

    @Autowired
    private UserService userService;
    @ResponseBody
    @GetMapping("/queryAllUser")
    public List<User> queryAllUser(){
        return userService.queryAllUser();
    }
    @ResponseBody
    @RequestMapping("/queryByIdUser")
    public User queryByIdUser(int Id){
        return userService.queryByIdUser(Id);
    }

    @ResponseBody
    @RequestMapping("/addUser")
    public int addUser(User user){
        return userService.addUser(user);
    }
    @ResponseBody
    @RequestMapping("/updateUser")
    public int updateUser(User user){
        return userService.updateUser(user);
    }
    @ResponseBody
    @RequestMapping("/deleteUser")
    public int deleteUser(int Id){
        return userService.deleteUser(Id);
    }
}
